package com.jianneng.jdg.model.adapter;

import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.com.jianneng.jdg.R;
import com.jianneng.jdg.model.user.AskInfo;

public class AskListAdapter extends BaseAdapter {
private Context context;
private LayoutInflater mInflater;
private List<AskInfo> list = new ArrayList<AskInfo>();
public AskListAdapter(Context context,List<AskInfo> list) {
	this.context = context;
	this.list = list;
	mInflater = LayoutInflater.from(context);
	
}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@SuppressLint("ViewHolder")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
//		//解决抢占焦点问题
//		ViewGroup vg = (ViewGroup) convertView;
//		vg.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
		View view = mInflater.inflate(R.layout.ask_listview_item, null);
		TextView  ask = (TextView) view.findViewById(R.id.ask);
		final TextView resolve = (TextView) view.findViewById(R.id.resolve_content);
		ImageView show = (ImageView) view.findViewById(R.id.ask_show);
		AskInfo info = list.get(position);
		ask.setText(info.ask);
		resolve.setText(info.solution);
			resolve.setMaxLines(2);
		show.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				resolve.setMaxLines(10);
				Toast.makeText(context, "1", 1).show();
				
				
			}
		});
		return view;
	}

}
